#include "HudEventReceiver.h"
#include "GuiCreator.h"
#include "Logger.h"

extern Logger* logger;

HudEventReceiver::HudEventReceiver(SAppContext & context) : Context(context)
{
}


HudEventReceiver::~HudEventReceiver()
{
}

bool HudEventReceiver::OnEvent(const SEvent& event)
{
	if (event.EventType == EET_KEY_INPUT_EVENT)
	{
		if (event.KeyInput.PressedDown == true)
		{
			EKEY_CODE key = event.KeyInput.Key;
			switch (key)
			{
				case KEY_ESCAPE:
				{
					logger->info("key pressed");
				}
				break;
				
				default:
					return false;
					break;
			}
		}
	}

	if (event.EventType == irr::EET_GUI_EVENT)
	{
		s32 id = event.GUIEvent.Caller->getID();
		switch (event.GUIEvent.EventType)
		{
		case EGET_BUTTON_CLICKED:
			switch (id)
			{
			case GuiCreator::GUI_ID_QUIT_BUTTON:
			{
				logger->info("button clicked");
				return true;
			}
			default:
				return false;
			}
			break;

		default:
			return false;

		}
	}
}